<?php
namespace app\serverfund\logic;

use \app\manage\logic\BaseLogic;
use \app\manage\service\ApiBase;
use \think\Db;

class Withdraw extends BaseLogic
{
    protected $withdrawValidate = '\app\serverfund\validate\Withdraw';
    protected $withdrawLogic = '\app\serverfund\logic\Withdraw';

    /*管理员审核提现*/
    public function auditWithdraw($data): array 
    {
    	//获取审核人信息
    	$service = new ApiBase($data['token']);
        $app_key = \app\manage\service\ApiBase::getAppKey();
        $request = \think\Request::instance();

    	$getBaseInfo['query'] = json_encode([
            ['path'=>'serveruser/auth/Token/hGetAll', 'param'=>['token'=>$data['token']]],
            ['path'=>'serveruser/auth/App/find', 'param'=>['app_key'=>$app_key]]
        ]);
		$baseInfo = ApiBase::sendDataLots(config('proxy_all_url'), $getBaseInfo);
		if($baseInfo['status'] != SUCCESS_STATUS){
			return $baseInfo;
		}

		//审核提现
        $data['update_ip'] = $request->ip();
        //$data['app_id'] = $baseInfo['res'][1]['id'];
    	$data['review_id'] = $baseInfo['res'][0]['id'];
    	$data['review_info'] = $baseInfo['res'][0];
    	$auditWithdraw['query'] = json_encode([['path'=>'serverfund/withdraw/Withdraw/auditWithdraw', 'param'=>$data]]);
    	return ApiBase::sendDataOne(config('proxy_all_url'), $auditWithdraw);
    }

    /*管理员审核转账*/
    public function auditTransfer($data): array 
    {
    	//获取审核人信息
    	$service = new ApiBase($data['token']);
        $app_key = \app\manage\service\ApiBase::getAppKey();

        $getBaseInfo['query'] = json_encode([
            ['path'=>'serveruser/auth/Token/hGetAll', 'param'=>['token'=>$data['token']]],
            ['path'=>'serveruser/auth/App/find', 'param'=>['app_key'=>$app_key]]
        ]);
        $baseInfo = ApiBase::sendDataLots(config('proxy_all_url'), $getBaseInfo);
        if($baseInfo['status'] != SUCCESS_STATUS){
            return $baseInfo;
        }

		//审核提现
    	$data['transfer_id'] = $baseInfo['res'][0]['id'];
    	$data['transfer_info'] = $baseInfo['res'][0];
        $data['update_ip'] = request()->ip();
    	$auditTransfer['query'] = json_encode([['path'=>'serverfund/withdraw/Withdraw/auditTransfer', 'param'=>$data]]);
    	return ApiBase::sendDataOne(config('proxy_all_url'), $auditTransfer);
    }




}